﻿using LogisticsTrackingWebApi_V2.Models;
using LogisticsTrackingWebApi_V2.Services;

namespace LogisticsTrackingWebApi_V2.ServicesImpl
{
    /// <summary>
    /// 京东物流查询实现
    /// </summary>
    public class JDLogisticsProvider : ILogisticsProvider
    {
        public string CompanyCode => "JD";
        public string CompanyName => "京东物流";

        public async Task<LogisticsInfo> QueryLogisticsAsync(string trackingNumber)
        {
            // 实际项目中这里会调用京东物流的API
            await Task.Delay(120); // 模拟API调用延迟

            return new LogisticsInfo
            {
                TrackingNumber = trackingNumber,
                CompanyCode = CompanyCode,
                CompanyName = CompanyName,
                Status = LogisticsStatus.OutForDelivery,
                LastUpdated = DateTime.Now.AddHours(-1),
                TrackingRecords = new List<TrackingRecord>
            {
                new TrackingRecord { Time = DateTime.Now.AddHours(-1), Location = "广州市天河区", Description = "快递员已出发，请保持电话畅通" },
                new TrackingRecord { Time = DateTime.Now.AddHours(-3), Location = "广州市", Description = "快件已分配快递员" },
                new TrackingRecord { Time = DateTime.Now.AddHours(-6), Location = "广州市", Description = "快件已到达目的地仓库" }
            }
            };
        }
    }

}
